#include "pch.h"
#include "BinTree.h"

void PostOrder_1(BinTreeNode *t) {
	if (t != NULL) {
		stack<StackNode> st;
		StackNode sn;
		BinTreeNode *p;
		do
		{
			while (t != NULL) {
				sn.ptr = t;
				sn.tag = L;
				st.push(sn);
				t = t->leftChild;
			}
			bool flag = true;
			while (flag&&st.empty()) {
				sn = st.top();
				st.pop();
				p = sn.ptr;
				switch (sn.tag)
				{
				case L:
					sn.tag = R;
					st.push(sn);
					flag = false;
					t = p->rightChild;
					break;
				case R:
					printf("%c", p->data);
					break;
				}
			}
		} while (!st.empty());
	}
}
void PostOrder_1(BinTree *bt) {
	PostOrder_1(bt->root);
}
